<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>文章列表</title>
  <link rel="stylesheet" href="/static/css/font.css">
  <link rel="stylesheet" href="/static/css/index.css">
  <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
  <script type="text/javascript" src="/static/js/index.js"></script>
</head>
<body>
<div class="x-nav">
  <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
    <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-body ">
          <form class="layui-form layui-col-space5" method="post" action="findAllLoveGuidesByLike">
            <div class="layui-inline layui-show-xs-block">
              <input type="text" name="guidanceTitle" placeholder="请输入文章标题" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-inline layui-show-xs-block">
              <input type="text" name="guidanceAuthor"  placeholder="请输入文章作者" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-inline layui-show-xs-block">
              <button class="layui-btn"  lay-submit="" lay-filter="sreach" type="submit"><i class="layui-icon">&#xe615;</i></button>
            </div>
          </form>
        </div>
        <div class="layui-card-body layui-table-body layui-table-main">
          <table class="layui-table layui-form" align="center">
            <thead >
            <tr>
              <th>ID</th>
              <th>标题</th>
              <th>作者</th>
              <th>内容</th>
              <th>发布时间</th>
              <th>转载于</th>
              <th>收藏量</th>
              <th>操作</th></tr>
            </thead>
            <tbody >
            <tr  th:each="list,listStat:${guidanceList}">
              <td th:text="${listStat.index+1}"></td>
              <td th:text="${list.guidanceTitle}" style="max-width: 100px;overflow: hidden; text-overflow:ellipsis;white-space: nowrap"></td>
              <td th:text="${list.guidanceAuthor}"></td>
              <td th:text="${list.guidanceContent}" style="max-width: 100px;overflow: hidden; text-overflow:ellipsis;white-space: nowrap"></td>
              <td th:text="${list.guidanceTime}"></td>
              <td th:text="${list.guidanceReproduced}" style="max-width: 100px;overflow: hidden; text-overflow:ellipsis;white-space: nowrap"></td>
              <td th:text="${list.guidanceNumber}"></td>
              <td class="td-manage">
                <!--<a title="编辑"  onclick="xadmin.open('编辑','updateGuidesPages')" href="javascript:;">
                  <i class="layui-icon">&#xe642;</i>
                </a>-->
                <a title="编辑" th:onclick="member_update(this,[[${list.guidanceId}]])" href="javascript:;">
                  <i class="layui-icon">&#xe642;</i>
                </a>
                <a title="删除" th:onclick="member_del(this,[[${list.guidanceId}]])" href="javascript:;">
                  <i class="layui-icon">&#xe640;</i>
                </a>
              </td>
            </tr>

            </tbody>
          </table>
        </div>
        <!--<div class="layui-card-body ">
          <div class="page">
            <div>
              <a class="prev" href="">&lt;&lt;</a>
              <a class="num" href="">1</a>
              <span class="current">2</span>
              <a class="num" href="">3</a>
              <a class="num" href="">489</a>
              <a class="next" href="">&gt;&gt;</a>
            </div>
          </div>
        </div>-->
      </div>
    </div>
  </div>
</div>
</body>
<script  th:inline="javascript">
  layui.use(['laydate','form'], function(){
    var laydate = layui.laydate;
    var  form = layui.form;


    // 监听全选
    form.on('checkbox(checkall)', function(data){

      if(data.elem.checked){
        $('tbody input').prop('checked',true);
      }else{
        $('tbody input').prop('checked',false);
      }
      form.render('checkbox');
    });

    //执行一个laydate实例
    laydate.render({
      elem: '#start' //指定元素
    });

    //执行一个laydate实例
    laydate.render({
      elem: '#end' //指定元素
    });


  });
  /*用户-删除*/
  function member_del(obj,id){
    layer.confirm('确认要删除吗？',function(index){
      $.ajax({
        url:'deleteGuidance',
        method:'post',
        async:false,
        data:{'guidanceId':id},
        success:function (data) {
          res=data;
          // alert(res)
        }
      });
      if (res=="1"){
        //发异步删除数据
        $(obj).parents("tr").remove();
        layer.msg('已删除!',{icon:1,time:1000});
      }else {
        window.location.href="toErrorPage"
      }
    });
  }
  /*用户-修改*/
  function member_update(obj,id){
    $.ajax({
      url:'updateGuidesPages',
      method:'post',
      async:false,
      data:{'guidanceId':id}
    });
    window.location.href="toUpdateGuidesPages"
  }
</script>
</html>